package com.hongyuan.sellfitness.ui.home.activity;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.sellfitness.BR;
import com.hongyuan.sellfitness.R;
import com.hongyuan.sellfitness.base.AppViewModelFactory;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.CustomActivity;
import com.hongyuan.sellfitness.databinding.ActivityStoreCoachBinding;
import com.hongyuan.sellfitness.ui.home.view_mode.StoreCoachViewModel;

public class StoreCoachActivity extends CustomActivity<ActivityStoreCoachBinding, StoreCoachViewModel> {

    private String os_id;

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_store_coach;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public StoreCoachViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用NetWorkViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(StoreCoachViewModel.class);
    }

    @Override
    public void initParam() {
        os_id = getBundle().getString("os_id");
    }

    @Override
    public void initView() {
        super.initView();

        setOnRefresh(binding.refresh,REFRESH_0X3);
        setEnableLoadMore(Constants.GET_COACH_LIST);
        setEnableRefresh(Constants.GET_COACH_LIST);

        binding.comBack.setOnClickListener(view -> finish());
    }

    @Override
    public void initData() {
        super.initData();

        viewModel.clearParams().setParams("os_id",os_id).setParams("os_ids",os_id);

        //请求门店信息
        viewModel.requestData(Constants.GET_OFFLINE_STORE_INFO);
        //请求教练
        viewModel.requestData(Constants.GET_COACH_LIST);
    }

}
